<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="hmg.common.ValueHolder"%>
<%@ page import="hmg.common.CommonUtils"%>
<%@ page import="hmg.vo.BoardVO"%>
<%@ page import="java.util.List"%>
<%-- 
    JSP Name : jspName.jsp
    Description : 설명을 기술합니다.
    author Kim hyung soo
    since 2012. 9. 20.
    version 1.0
    Modification Information
       since          author              description
    ===========    =============    ===========================
    2012. 9. 20.     Kim hyung soo     최초 생성
--%>
<%
    String currPage = CommonUtils.getParameter(request.getParameter("page"), "1");
    String totalSearches = CommonUtils.getParameter(request.getParameter("totalSearches"), "0");
    String dicts = CommonUtils.getParameter(request.getParameter("dicts"), "0");
    String news = CommonUtils.getParameter(request.getParameter("news"), "0");
    String acts = CommonUtils.getParameter(request.getParameter("acts"), "0");
    String recs = CommonUtils.getParameter(request.getParameter("recs"), "0");
    String vods = CommonUtils.getParameter(request.getParameter("vods"), "0");
    String photos = CommonUtils.getParameter(request.getParameter("photos"), "0");
    String searchKeyword = CommonUtils.getDecodedParameter(request.getParameter("searchKeyword"), "");

    List<BoardVO> vodList = (List<BoardVO>) request.getAttribute("VodList");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="ko" xml:lang="ko" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>통합검색 | 현대자동차그룹</title>
<meta name="description" content="현대자동차그룹 홈페이지 내 통합 검색하기" />
<meta name="keywords" content="현대자동차그룹 통합검색, 현대차그룹, 통합검색, 통합검색, 검색" />
<%@ include file="/WEB-INF/jsp/web/kor/include/header.jspf" %>
<script type="text/javascript" src="/hmg/js/web/kor/com/swfobject.js"></script>
<script type="text/javascript">
var page = "<%= currPage %>";
var totalSearches = "<%= totalSearches %>";
var dicts = "<%= dicts %>";
var news = "<%= news %>";
var acts = "<%= acts %>";
var recs = "<%= recs %>";
var vods = "<%= vods %>";
var photos = "<%= photos %>";

$(document).ready(function(){
    if (page == "")
        page = "1";

    $("#paging").html(getNewsPagingString(<%= vods %>, page, 12, 10)); 
});

function fn_search() {
    var keyword = $("#searchKeyword").val();
    
    if (keyword == "") {
        alert("검색어를 입력해 주세요.");
        return;
    }
    else if (keyword.length < 2) {
        alert("검색어를 2자 이상 입력해 주세요.");
        return;
    }

    document.location.href = "./UnifiedSearch.do?searchKeyword=" + escape(encodeURIComponent(keyword)) + "&page=1";
}

function fn_search_result(listType) {
    var keyword = escape(encodeURIComponent($("#searchKeyword").val()));
    
    switch (listType) {
        case 0 : document.location.href = "/hmg/web/kor/sch/trm/TermDictionaryList.do?searchKeyword=" + keyword; break;
        case 1 : document.location.href = "/hmg/web/kor/sch/nfd/UnifiedSearch.do?searchKeyword=" + keyword; break;
        case 2 : document.location.href = "/hmg/web/kor/sch/nfd/UnifiedSearchNews.do?searchKeyword=" + keyword + "&totalSearches=" + totalSearches + "&dicts=" + dicts + "&news=" + news + "&acts=" + acts + "&recs=" + recs + "&vods=" + vods + "&photos=" + photos + "&page=1"; break;
        case 3 : document.location.href = "/hmg/web/kor/sch/nfd/UnifiedSearchAct.do?searchKeyword=" + keyword + "&totalSearches=" + totalSearches + "&dicts=" + dicts + "&news=" + news + "&acts=" + acts + "&recs=" + recs + "&vods=" + vods + "&photos=" + photos + "&page=1"; break;
        case 4 : document.location.href = "/hmg/web/kor/sch/nfd/UnifiedSearchRecruit.do?searchKeyword=" + keyword + "&totalSearches=" + totalSearches + "&dicts=" + dicts + "&news=" + news + "&acts=" + acts + "&recs=" + recs + "&vods=" + vods + "&photos=" + photos + "&page=1"; break;
        case 5 : document.location.href = "/hmg/web/kor/sch/nfd/UnifiedSearchVod.do?searchKeyword=" + keyword + "&totalSearches=" + totalSearches + "&dicts=" + dicts + "&news=" + news + "&acts=" + acts + "&recs=" + recs + "&vods=" + vods + "&photos=" + photos + "&page=1"; break;
        case 6 : document.location.href = "/hmg/web/kor/sch/nfd/UnifiedSearchPhoto.do?searchKeyword=" + keyword + "&totalSearches=" + totalSearches + "&dicts=" + dicts + "&news=" + news + "&acts=" + acts + "&recs=" + recs + "&vods=" + vods + "&photos=" + photos + "&page=1"; break;
    }
}

function fn_move_page(pageNo){
    fn_common_move_page(pageNo, location.search, page, 12, <%= vods %>, "./UnifiedSearchVod.do");
}

//동영상갤러리
$(function() {
    usrAgnt = navigator.userAgent;

    if(usrAgnt.indexOf("Mobile") < 0){
        // non flash
        $(function(){
            var playerVersion = swfobject.getFlashPlayerVersion();
            if (playerVersion.major == 0) {
                $("#topNavi").remove();
                $(".alterText").show();
            }
        });
    }else {
        $("#topNavi").remove();
        $("#tablet-broadcastView").show();
        $(".alterText").remove();
    }
});

function closePlayer() {
    getMovieName("topNavi").closePlayer();
}

function playerSoundOff() {
    getMovieName("topNavi").videoStop();
}

function getMovieName(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }else {
        return document[movieName]
    }
}

function fn_play_movie(listID) {
    $("#movieLayer").html("");
    
    $.ajax({
        type:"post",
        url:"./AjaxPlayMovie.do",
        data:({listID:listID}),
        success: function(data) { fn_play_movie_proc(data); }
    });
}

function fn_play_movie_proc(data) {
    $("#movieLayer").html(data);
    
    fe_layPop_vod();
    
    $("#noticeWrap").css({"z-index":"-1"});
    $("#footer").css({"z-index":"-2"});

    var maskHeight = $(document).height();
    var maskWidth = $(window).width();
    var layerHeight = $(".vod_layPop > div").height();
    var layerWidth = $(".vod_layPop > div").width();
    $(".vod_layer").css({"width":maskWidth,"height":maskHeight, "display": "block"});
    $(".vod_layPop").css({"margin-top": "-" + layerHeight/2 + "px", "margin-left" : "-" + layerWidth/2 + "px"});
}

</script>
</head>
<body>
    <!--wrap-->
    <div id="wrap">
        <!-- skip navigation -->
        <div id="skipnavition">
            <a href="#gnb">메뉴바로가기</a><a href="#content">본문바로가기</a>
        </div>
        <!--// skip navigation -->

        <hr />

        <!-- header-->
        <%@ include file="/WEB-INF/jsp/web/kor/include/left.jspf" %>
        <!--//header-->

        <hr />

        <!--container-->
        <div id="container">
            <div class="scroll-pane">
                <!-- 공통 -->
                <div class="subTitle">
                    <div class="pageTitle">
                        <h2><img src="/hmg/images/web/kor/title/sch_Totalsearch.gif" alt="통합검색" /></h2>
                    </div> 
                    <div class="pageLocation">
                        <ul>
                            <li><a href="/hmg/web/kor/Main.do"><img src="/hmg/images/web/kor/common/location_home.gif" alt="홈"/></a></li>
                            <li class="nowPage"><a href="/hmg/web/kor/sch/nfd/UnifiedSearch.do">통합검색</a></li>
                        </ul>
                    </div>
                </div>
                <!--//공통-->

                <!--contents-->
                <div id="content">
                    <!-- 내용 -->
                    <div class="total_search">
                        <div class="total_searchBox">
                            <img src="/hmg/images/web/kor/sch/total_Search_Text01.gif" alt="상세검색" class="search_text"/>
                            <label class="hidden" for="searchKeyword">검색</label>
                            <input type="text" title="검색" id="searchKeyword" name="searchKeyword" value="<%= searchKeyword %>" onkeypress="javascript:if (event.keyCode==13) {fn_search();}" maxlength="50"/>
                            <a href="javascript:fn_search();"><img src="/hmg/images/web/kor/btn/btn_search.gif" alt="검색"  class="btn"/></a>
                        </div>

<%  if (searchKeyword != "") { %>
                        <p class="total_search_result">&quot;<span><%= searchKeyword %></span>&quot; 에 대한 검색결과가 총 <span><%= totalSearches %></span>건이 있습니다.</p>
<%  } %>
                
                        <div class="total_searchTab">
                            <ul class="tabs">
                                <li class="tab1"><a href="#" onclick="javascript:fn_search_result(1);">통합검색 (<span class="count"><%= totalSearches %></span>)</a></li>
                                <li class="tab2"><a href="#" onclick="javascript:fn_search_result(2);">그룹소식 (<span class="count"><%= news %></span>)</a></li>
                                <li class="tab3"><a href="#" onclick="javascript:fn_search_result(3);" >사회공헌 (<span class="count"><%= acts %></span>)</a></li>
                                <li class="tab4"><a href="#" onclick="javascript:fn_search_result(4);">인재채용 (<span class="count"><%= recs %></span>)</a></li>
                                <li class="tab5"><a href="#" onclick="javascript:fn_search_result(5);" class="on">영상 (<span class="count"><%= vods %></span>)</a></li>
                                <li class="tab6"><a href="#" onclick="javascript:fn_search_result(6);">이미지 (<span class="count"><%= photos %></span>)</a></li>
                            </ul>
                        </div>

                        <!-- tabCont5  S// -->
                        <div id="tab_content05" class="tab_content">
                            <div class="titleWrap">
                                <div class="left"><h3>동영상 (<span class="list_count"><%= vods %>건</span>)</h3></div>
                            </div>

                            <div class="search_result_gallery">
<%  if (vodList == null || vodList.size() == 0) { %>
                            
                                    </br><dl class="photo_layOpen" style="text-align:center;width:100%;">검색된 게시물이 없습니다.</dl>
<%
    }
    else {
        for (int idx = 0; idx < vodList.size(); idx++) {
            BoardVO searchVod = vodList.get(idx);
    
            String dlClassName = "";
    
            if ((idx + 1) % 4 == 0)
                dlClassName = " last";
%>
                                <dl class="<%= dlClassName %>">
                                    <dt><a href="javascript:fn_play_movie(<%= searchVod.getListID() %>);" class="vod_layOpen"><%= searchVod.getTitle() %></a></dt>
                                    <dd class="etc_information"><span>영상갤러리</span> <%= searchVod.getRegDate() %></dd>
                                    <dd class="video-play"><a href="#" onclick="javascript:fn_play_movie(<%= searchVod.getListID() %>);" class="vod_layOpen"><span>VIDEO PLAY</span></a></dd>
                                    <dd class="gallery_image"><a href="#" onclick="javascript:fn_play_movie(<%= searchVod.getListID() %>);" class="vod_layOpen"><img src="<%= searchVod.getThumbnailImage() %>" style="width:146px; height:146px; border:0px;" alt="영상갤러리 검색결과 이미지"/></a></dd>
                                </dl>
<%
        }
    }
%>
                            </div>
                        
                            <div class="gropnews_page mt20">
                                <div class="gropnews_page_left">
                                    <ul id="paging"></ul>
                                </div>

                                <div class="gropnews_page_right">
                                    <ul>
                                        <li><a href="javascript:fn_move_page('prev');"><img src="/hmg/images/web/kor/btn/btn_prev.gif" alt="이전페이지로 이동" /></a></li>
                                        <li><a href="javascript:fn_move_page('next');"><img src="/hmg/images/web/kor/btn/btn_next.gif" alt="다음페이지로 이동" /></a></li>
                                    </ul>
                                </div>
                            </div>

                        </div>
                        <!-- tabCont5  E// -->
                    </div>  
                </div>
                <!--// 내용 -->

                <!-- 동영상layer -->
                <div class="vod_layer" id="movieLayer"></div>
                <!-- //동영상layer -->
            </div>
            <!--//contents-->
        </div>
        <!--//container-->

        <hr />

        <!--footer-->
        <%@ include file="/WEB-INF/jsp/web/kor/include/footer.jspf" %>
        <!--//footer-->
        <hr />
        <!--notice-->
        <%@ include file="/WEB-INF/jsp/web/kor/include/notice.jspf" %>
        <!--//notice-->
    </div>
    <!--//wrap-->
</body>
</html>